package com.qiangqiang.task.server.mapper.provider;

import com.qiangqiang.task.server.entity.Follow;
import com.qiangqiang.task.server.entity.Message;
import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

/**
 * @program: task
 * @description:
 * @author: Sky.lin
 * @create: 2019-03-06 13:22
 **/
public class MessageProvider extends BaseProvider {
    public String insertMessage(final Map<String, Object> map) {
        Message message = (Message) map.get("message");
        return generateInsertSQL(Message.class);
    }

    public String queryPageMessageByToId(final Map<String, Object> map) {
        long toId = (long) map.get("toId");
        SQL sql = new SQL() {
            {
                SELECT("*");
                FROM("message");
                WHERE("to_id=" + toId);
            }
        };
        StringBuffer sb = new StringBuffer(sql.toString());
        sb.append(getLimit(1, 10));
        return sql.toString();
    }
}
